<template>
  <div class="menu">
    <el-menu
        default-active="/home"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#7369EF"
        text-color="#cddde9"
        active-text-color="#fff"
        :unique-opened="true"
        :router="true">


      <el-menu-item index="/home">
        <i class="el-icon-s-opportunity"></i>
        <span slot="title">系统首页</span>
      </el-menu-item>

      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-s-custom"></i>
          <span>人员管理</span>
        </template>
          <el-menu-item index="/account" v-if="role ==1">账号管理</el-menu-item>
          <el-menu-item index="/updatePassword">修改密码</el-menu-item>
        </el-submenu>

      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-star-on"></i>
          <span>基础配置</span>
        </template>
        <el-menu-item index="/ColonyHouse">圈舍管理</el-menu-item>
        <el-menu-item index="/ranch">牧场管理</el-menu-item>
      </el-submenu>

</el-menu>
  </div>
</template>

<script>
export default {
  data(){
    return{
      role:''
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }

  },
  created(){
    let user = JSON.parse(localStorage.getItem('user'))
    this.role = user.role

  }
}
</script>

<style lang="less" scoped>
.menu{
  width: 300px;
  height: 100%;
  background: #7369EF;

}

</style>